use std::collections::HashMap;
use url::Url;

/// 暂时只支持 GET, POST
#[derive(Debug, Clone)]
pub enum Method {
    GET,
    POST,
}

#[derive(Debug, Clone)]
pub enum RequestBody {
    Form(HashMap<String, String>),
    Empty,
}

/// 自定义 Request, 含 parser
/// body 暂时只支持 form 发送
#[derive(Debug, Clone)]
pub struct Request {
    pub url: Url,
    pub method: Method,
    pub headers: Option<HashMap<&'static str, String>>,
    pub query: Option<HashMap<String, String>>,
    pub body: RequestBody,
}

impl Request {
    pub fn new(
        url: Url,
        method: Method,
        headers: Option<HashMap<&'static str, String>>,
        query: Option<HashMap<String, String>>,
        body: RequestBody,
    ) -> Self {
        Self {
            url,
            method,
            headers,
            query,
            body,
        }
    }
}
